package com.suse.service.admin.edu.controller;

import com.suse.common.config.response.R;
import com.suse.service.admin.edu.model.param.CourseQueryQueryParam;
import com.suse.service.admin.edu.model.param.CourseSaveParam;
import com.suse.service.admin.edu.model.param.CourseUpdateParam;
import com.suse.service.admin.edu.service.CourseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 * 课程 前端控制器
 * </p>
 *
 * @author 辜玉彬
 * @since 2022-08-11
 */
@Api(tags = "课程接口")
@RestController
@RequestMapping("/course")
public class CourseController {

    @Resource
    private CourseService courseService;

    @ApiOperation(value = "获取课程表格(分页)")
    @PostMapping("/table")
    public R getCourseTable(@RequestBody CourseQueryQueryParam courseQueryParam) {
        return courseService.getCourseTable(courseQueryParam);
    }

    @ApiOperation(value = "通过ID获取课程信息")
    @GetMapping("/info/{id}")
    public R getCourseInfoById(@PathVariable("id") String id) {
        return courseService.getCourseInfoById(id);
    }

    @ApiOperation(value = "通过ID获取课程发布信息")
    @GetMapping("/publish-info/{id}")
    public R getCoursePublishInfoById(@PathVariable("id") String id) {
        return courseService.getCoursePublishInfoById(id);
    }

    @ApiOperation(value = "通过ID发布课程")
    @GetMapping("/publish/{id}")
    public R publishCourseById(@PathVariable("id") String id) {
        return courseService.publishCourseById(id);
    }

    @ApiOperation(value = "获取课程发布步骤")
    @GetMapping("/step/{id}")
    public R getCourseStep(@PathVariable("id") String id) {
        return courseService.getCourseStep(id);
    }

    @ApiOperation(value = "添加课程")
    @PostMapping("/save")
    public R saveCourse(@Valid @RequestBody CourseSaveParam courseSaveParam) {
        return courseService.saveCourse(courseSaveParam);
    }

    @ApiOperation(value = "修改课程")
    @PostMapping("/update")
    public R updateCourse(@Valid @RequestBody CourseUpdateParam CourseUpdateParam) {
        return courseService.updateCourse(CourseUpdateParam);
    }

    @ApiOperation(value = "通过ID删除课程")
    @DeleteMapping("/remove/{id}")
    public R removeCourseById(@PathVariable("id") String id) {
        return courseService.removeCourseById(id);
    }

}

